package design_pattern;


import design_pattern.WaitingRequestQueue.Request;

/**
 * @Author: 蔡翔
 * @Date: 2019/10/30 21:10
 * @Version 1.0
 *
 * 类B 属于 线程A， 当程序执行到 类B 某处被wait住了后，打断A线程，B类 捕捉wait 异常的 方法 会感知到。
 */
public class Test extends Thread {
    RequestAA requestAA = new RequestAA();
    @Override
    public void run() {
        System.out.println("Test 当前线程名是："+Thread.currentThread().getName());
        requestAA.get();
    }

    public void shutdown(){
        this.interrupt();
    }

}
class BootApplication{
    public static void main(String[] args) throws InterruptedException {
        Test test = new Test();
        test.start();

        Thread.sleep(3000);
        test.shutdown();
    }
}
class RequestAA{
    private final Object lock = new Object();
    public void get(){
        System.out.println("RequestAA 当前线程名是："+Thread.currentThread().getName());
        synchronized (lock){
            try {
                lock.wait();
            }catch (Exception e){
                System.out.println("我被捕捉到了");
            }
        }
    }
}
